package com.naire.modul.projecperiods.action;

import java.util.ArrayList;
import java.util.List;

import net.common.action.GeneralAction;

import com.naire.modul.projecperiods.service.ProjecperiodsDeleteService;
import com.naire.modul.projecperiods.service.ProjecperiodsEditorListService;
import com.naire.modul.projecperiods.service.ProjecperiodsEditorService;
import com.naire.modul.projecperiods.service.ProjecperiodsFindService;
import com.naire.modul.projecperiods.service.ProjecperiodsSearchService;
import com.naire.modul.projecperiods.vo.ProjecperiodsVo;

public class ProjecperiodsAction extends GeneralAction {

	private static final long serialVersionUID = 7127573666355745443L;

	private ProjecperiodsVo bean = new ProjecperiodsVo();
	private List<ProjecperiodsVo> list = new ArrayList<ProjecperiodsVo>();
	private Integer project_id;

	public String search() throws Exception {
		ProjecperiodsSearchService service = new ProjecperiodsSearchService();
		service.setPageBean(pageBean);
		service.setProject_id(project_id);
		service.invoke();
		list = service.getList();
		return SUCCESS;
	}

	public String editor() throws Exception {
		ProjecperiodsEditorService service = new ProjecperiodsEditorService();
		bean.setProject_id(project_id);
		service.setBean(bean);
		service.invoke();
		return SUCCESS;
	}

	public String editorList() throws Exception {
		ProjecperiodsEditorListService service = new ProjecperiodsEditorListService();
		service.setBean(bean);
		service.setList(list);
		service.invoke();
		return SUCCESS;
	}

	public String find() throws Exception {
		if (bean.getPeriods_id() != null) {
			ProjecperiodsFindService service = new ProjecperiodsFindService();
			service.setId(bean.getPeriods_id());
			service.invoke();
			bean = service.getBean();
		}
		return SUCCESS;
	}

	public String delete() throws Exception {
		ProjecperiodsDeleteService service = new ProjecperiodsDeleteService();
		service.setBean(bean);
		service.invoke();
		return SUCCESS;
	}

	public ProjecperiodsVo getBean() {
		return bean;
	}

	public void setBean(ProjecperiodsVo bean) {
		this.bean = bean;
	}

	public List<ProjecperiodsVo> getList() {
		return list;
	}

	public void setList(List<ProjecperiodsVo> list) {
		this.list = list;
	}

	public Integer getProject_id() {
		return project_id;
	}

	public void setProject_id(Integer project_id) {
		this.project_id = project_id;
	}
}
